<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="机构管理">
<style>
    /***循环的表单设置***/
    .bui-select .bui-select-input {
        width: 250px;
    }

    hr {
        border-color: #009688;
    }
</style>
<div class="xm-offline">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a href="${basepath}/manage/organize/toList">返回上一级</a>
            </div>
            <div class="panel-body">
                <form id="detailsForm" class="form-horizontal" action="${basepath}/manage/organize/updateJson"
                      method="post">
                    <input type="hidden" class="control-text span-width span10" name="id" value="${e.id!}" id="id">

                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构名称：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="name" value="${e.name!}"
                                   disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            负责人：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="principal"
                                   value="${e.principal!}" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系电话：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="principalPhone"
                                   value="${e.principalPhone!}" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构编码：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="id"
                                   disabled="disabled" value="${e.id!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            成立时间：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="buildTime"
                                   disabled="disabled" value="${e.buildTime!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            入驻日期：
                        </label>

                        <div class="controls">
                            <input type="text" class="tel control-text span-width span10" name="createTime"
                                   value="${e.createTime!}" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            所在地区：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span2" name="province"
                                   value="${e.province!}" disabled="disabled"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span2" name="city" value="${e.city!}"
                                   disabled="disabled"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span2" name="area" value="${e.area!}"
                                   disabled="disabled"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span10" name="address"
                                   value="${e.address!}" disabled="disabled"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            意向服务领域：
                        </label>

                        <div class="controls">
                            <input class="control-text span-width  span6" type="text" name="field"
                                   value="${e.field!}"
                                   disabled="disabled"/>
                        </div>
                    </div>
                    <div class="control-group" id="organization-img">
                        <label class="control-label">
                            <s>*</s>
                            机构图片：
                        </label>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构介绍：
                        </label>

                        <div class="controls control-row12" style="height: 350px;initialFrameWidth: 100%;">
                            <textarea type="text" class="input-large" name="content"
                                      id="content">${e.content!}</textarea>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构二维码：
                        </label>
                        <img src="/${e.qrCode!}" style="height: 100px;width: 100px;margin:0 0 10px 10px"/>
                    </div>

                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构级别：</label>

                        <div class="controls">
                            <input type="text" class="control-text" name="rank" value=""
                                   disabled="disabled" id="rank"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            上级机构：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width " id="parentID" disabled>
                        </div>
                    </div>
                    <h3 class="offset2">下级机构
                    </h3>
                    <hr/>
                    <input type="hidden" class="control-text span-width " name="subID" id="sub" value="${e.id!}">

                    <div id="subGrid" class="sub-grid"></div>
                    <div class="control-group">
                        <label class="control-label">
                            星级评价：
                        </label>
                    </div>
                    <div class="star-div">
                        <ul class="star-ul">
                            <li>
                                <p>公益信息准确性：</p>

                                <form>
                                    <div id="starBgInformation" class="star_bg">
                                        <input type="radio" id="starInformationScore1"
                                               class="score score_1 scoreInformation" value="1"
                                               name="score">
                                        <a href="#starInformationScore1" class="star star_1" title="差"
                                           id="starInformation"><label
                                                for="starInformationScore1" class="label-star">差</label></a>
                                        <input type="radio" id="starInformationScore2"
                                               class="score score_2 scoreInformation" value="2"
                                               name="score">
                                        <a href="#starInformationScore2" class="star star_2" title="较差"><label
                                                for="starInformationScore2" class="label-star">较差</label></a>
                                        <input type="radio" id="starInformationScore3"
                                               class="score score_3 scoreInformation" value="3"
                                               name="score">
                                        <a href="#starInformationScore3" class="star star_3" title="普通"><label
                                                for="starInformationScore3" class="label-star">普通</label></a>
                                        <input type="radio" id="starInformationScore4"
                                               class="score score_4 scoreInformation" value="4"
                                               name="score">
                                        <a href="#starInformationScore4" class="star star_4" title="较好"><label
                                                for="starInformationScore4" class="label-star">较好</label></a>
                                        <input type="radio" id="starInformationScore5"
                                               class="score score_5 scoreInformation" value="5"
                                               name="score">
                                        <a href="#starInformationScore5" class="star star_5" title="好"><label
                                                for="starInformationScore5" class="label-star">好</label></a>
                                    </div>
                                </form>
                            </li>
                            <li>
                                <p>公益管理专业性：</p>

                                <form>
                                    <div id="starBgManage" class="star_bg">
                                        <input type="radio" id="starManageScore1" class="score score_1 scoreManage"
                                               value="1" name="score">
                                        <a href="#starManageScore1" class="star star_1" title="差"><label
                                                for="starManageScore1" class="label-star">差</label></a>
                                        <input type="radio" id="starManageScore2" class="score score_2 scoreManage"
                                               value="2" name="score">
                                        <a href="#starManageScore2" class="star star_2" title="较差"><label
                                                for="starManageScore2" class="label-star">较差</label></a>
                                        <input type="radio" id="starManageScore3" class="score score_3 scoreManage"
                                               value="3" name="score">
                                        <a href="#starManageScore3" class="star star_3" title="普通"><label
                                                for="starManageScore3" class="label-star">普通</label></a>
                                        <input type="radio" id="starManageScore4" class="score score_4 scoreManage"
                                               value="4" name="score">
                                        <a href="#starManageScore4" class="star star_4" title="较好"><label
                                                for="starManageScore4" class="label-star">较好</label></a>
                                        <input type="radio" id="starManageScore5" class="score score_5 scoreManage"
                                               value="5" name="score">
                                        <a href="#starManageScore5" class="star star_5" title="好"><label
                                                for="starManageScore5" class="label-star">好</label></a>
                                    </div>
                                </form>
                            </li>
                            <li>
                                <p>公益行为延续性：</p>

                                <form>
                                    <div id="starBgBehavior" class="star_bg">
                                        <input type="radio" id="starBehaviorScore1" class="score score_1 scoreBehavior"
                                               value="1" name="score">
                                        <a href="#starBehaviorScore1" class="star star_1" title="差"><label
                                                for="starBehaviorScore1" class="label-star">差</label></a>
                                        <input type="radio" id="starBehaviorScore2" class="score score_2 scoreBehavior"
                                               value="2" name="score">
                                        <a href="#starBehaviorScore2" class="star star_2" title="较差"><label
                                                for="starBehaviorScore2" class="label-star">较差</label></a>
                                        <input type="radio" id="starBehaviorScore3" class="score score_3 scoreBehavior"
                                               value="3" name="score">
                                        <a href="#starBehaviorScore3" class="star star_3" title="普通"><label
                                                for="starBehaviorScore3" class="label-star">普通</label></a>
                                        <input type="radio" id="starBehaviorScore4" class="score score_4 scoreBehavior"
                                               value="4" name="score">
                                        <a href="#starBehaviorScore4" class="star star_4" title="较好"><label
                                                for="starBehaviorScore4" class="label-star">较好</label></a>
                                        <input type="checkbox" id="starBehaviorScore5"
                                               class="score score_5 scoreBehavior" value="5" name="score">
                                        <a href="#starBehaviorScore5" class="star star_5" title="好"><label
                                                for="starBehaviorScore5" class="label-star">好</label></a>
                                    </div>
                                </form>
                            </li>
                            <li>
                                <p>受助对象满意度：</p>

                                <form>
                                    <div id="starBgObject" class="star_bg">
                                        <input type="radio" id="starObjectScore1" class="score score_1 scoreObject"
                                               value="1" name="score">
                                        <a href="#starObjectScore1" class="star star_1" title="差"><label
                                                for="starObjectScore1" class="label-star">差</label></a>
                                        <input type="radio" id="starObjectScore2" class="score score_2 scoreObject"
                                               value="2" name="score">
                                        <a href="#starObjectScore2" class="star star_2" title="较差"><label
                                                for="starObjectScore2" class="label-star">较差</label></a>
                                        <input type="radio" id="starObjectScore3" class="score score_3 scoreObject"
                                               value="3" name="score">
                                        <a href="#starObjectScore3" class="star star_3" title="普通"><label
                                                for="starObjectScore3" class="label-star">普通</label></a>
                                        <input type="radio" id="starObjectScore4" class="score score_4 scoreObject"
                                               value="4" name="score">
                                        <a href="#starObjectScore4" class="star star_4" title="较好"><label
                                                for="starObjectScore4" class="label-star">较好</label></a>
                                        <input type="radio" id="starObjectScore5" class="score score_5 scoreObject"
                                               value="5" name="score">
                                        <a href="#starObjectScore5" class="star star_5" title="好"><label
                                                for="starObjectScore5" class="label-star">好</label></a>
                                    </div>
                                </form>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>
</div>
<script type="text/javascript">
    //ueditor编辑器不可编辑状态
    var editor = UE.getEditor('content', {
        readonly: true
    });
    var Grid = BUI.Grid;
    var Store = BUI.Data.Store;
    var imagesStore = new Store({});
    var Select = BUI.Select, Data = BUI.Data;
    var editForm = new BUI.Form.Form({
        srcNode: '#detailsForm',
        submitType: 'ajax',
        callback: function (data) {
        }
    }).render();

    //对机构级别的状态做判断塞值到input中
    var rank = "${e.rank!}";
    if (rank == "1") {
        $("#rank").val("A级");
    }
    if (rank == "2") {
        $("#rank").val("B级");
    }
    if (rank == "3") {
        $("#rank").val("C级");
    }
    /*--------------------------上级机构 begin --------------------*/

    /*--------------------------下级列表  begin--------------------*/
    var subColumns = [
        {
            title: '机构名称', dataIndex: 'name', width: '50%'
        }
    ];
    var subStore = new Store({
        url: '${basepath}/manage/organize/selectSubList',
        autoLoad: true,
        params: {
            id: $("#id").val()
        },
        root: 'data'
    });
    var subGrid = new Grid.Grid({
        render: '#subGrid',
        width: '100%',//如果表格使用百分比，这个属性一定要设置
        columns: subColumns,
        idField: 'title',
        store: subStore
    });
    subGrid.render();
    /*--------------------------下级列表  end--------------------*/
    /*--------------------------多张机构图片分割  begin--------------------*/
    var imgArr = "${e.picture!}".split(",");
    var imgHtml = "";
    for (var i = 0; i < imgArr.length; i++) {
        imgHtml += '<img src="${basepath}/' + imgArr[i] + '"/ style="height: 100px;width: 100px;margin:0 0 10px 10px" />';//创建img标签，图片地址赋值src
    }
    document.getElementById("organization-img").innerHTML += imgHtml;
    /*--------------------------多张机构图片分割  end--------------------*/
    function detail() {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "${basepath}/manage/organize/selectSupList",
            data: {
                id: $("#id").val()
            },
            success: function (data) {
                $("#parentID").val(data.data[0].name);
            }
        });
    }
    detail();

    //那些label 和input 绑定click事件
    $(".score").click(function (e) {
        e.preventDefault();
    });
    $(".label-star").click(function (e) {
        e.preventDefault();

    });
    //取机构id的值
    function getQueryString(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(r[2]);
        }
        return null;
    }

    //当前活动id
    var id = getQueryString("id");

    function queryOrganize() {
        $.ajax({
            type: "GET",
            url: "/manage/organizeComment/selectOrganizeComment",
            dataType: 'json',
            data: {
                organizeID:id
            },
            success: function (data) {
                var organizeComment = data.data;
                //对星级做处理
                //对公益信息准确性塞值
                if (organizeComment.veracity == "1") {
                    $('#starInformationScore1').prop('checked', true);
                } else if (organizeComment.veracity == "2") {
                    $('#starInformationScore2').prop('checked', true);
                } else if (organizeComment.veracity == "3") {
                    $('#starInformationScore3').prop('checked', true);
                } else if (organizeComment.veracity == "4") {
                    $('#starInformationScore4').prop('checked', true);
                } else if (organizeComment.veracity == "5") {
                    $('#starInformationScore5').prop('checked', true);
                } else {
                    return;
                }
                //对公益管理专业性塞值
                if (organizeComment.speciality == "1") {
                    $('#starManageScore1').prop('checked', true);
                } else if (organizeComment.speciality == "2") {
                    $('#starManageScore2').prop('checked', true);
                } else if (organizeComment.speciality == "3") {
                    $('#starManageScore3').prop('checked', true);
                } else if (organizeComment.speciality == "4") {
                    $('#starManageScore4').prop('checked', true);
                } else if (organizeComment.speciality == "5") {
                    $('#starManageScore5').prop('checked', true);
                } else {
                    return;
                }
                //对公益行为延续性塞值
                if (organizeComment.continuity == "1") {
                    $('#starBehaviorScore1').prop('checked', true);
                } else if (organizeComment.continuity == "2") {
                    $('#starBehaviorScore2').prop('checked', true);
                } else if (organizeComment.continuity == "3") {
                    $('#starBehaviorScore3').prop('checked', true);
                } else if (organizeComment.continuity == "4") {
                    $('#starBehaviorScore4').prop('checked', true);
                } else if (organizeComment.continuity == "5") {
                    $('#starBehaviorScore5').prop('checked', true);
                } else {
                    return;
                }
                //对受助对象满意度塞值
                if (organizeComment.satisfaction == "1") {
                    $('#starObjectScore1').prop('checked', true);
                } else if (organizeComment.satisfaction == "2") {
                    $('#starObjectScore2').prop('checked', true);
                } else if (organizeComment.satisfaction == "3") {
                    $('#starObjectScore3').prop('checked', true);
                } else if (organizeComment.satisfaction == "4") {
                    $('#starObjectScore4').prop('checked', true);
                } else if (organizeComment.satisfaction == "5") {
                    $('#starObjectScore5').prop('checked', true);
                } else {
                    return;
                }
                //那些label 和input 绑定click事件
                $(".score").click(function (e) {
                    e.preventDefault();

                });
                $(".label-star").click(function (e) {
                    e.preventDefault();
                });

            }

        })
    }

    queryOrganize();
</script>
</@page.pageBase>